package com.sskj.motherboard.controller;

import com.sskj.common.util.ApiResponseUtil;
import com.sskj.common.util.StrUtil;
import com.sskj.common.vo.ApiResponse;
import com.sskj.common.vo.req.PushCameraStreamReq;
import com.sskj.motherboard.service.IMotherboardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/motherboard/ptz")
public class PTZController {

    @Autowired
    private IMotherboardService motherboardService;

    // 摄像头推流
    @GetMapping("pushCameraStream")
    public ApiResponse<Object> pushCameraStream(PushCameraStreamReq req) {
        boolean b = motherboardService.pushCameraStream(req.getDeviceId(), req.getChannelNumber(), req.getVideoQualityType());
        if (b) {
            return ApiResponseUtil.success();
        } else {
            return ApiResponseUtil.fail();
        }
    }

    // 停止摄像头推流
    @GetMapping("stopCameraStream")
    public ApiResponse<Object> stopCameraStream(PushCameraStreamReq req) {
        if (!StrUtil.isBlank(req.getDeviceId()) && (req.getChannelNumber() != null && req.getChannelNumber() > 0)) {
            motherboardService.stopCameraStream(req.getDeviceId(), req.getChannelNumber());
        }

        return ApiResponseUtil.success();
    }
}
